xen/arm: p2m: Release the p2m lock before undoing the mappings
authorJulien Grall <julien.grall@arm.com>
Fri, 20 May 2016 13:37:42 +0000 (14:37 +0100)
committerStefano Stabellini <sstabellini@kernel.org>
Sat, 21 May 2016 15:16:54 +0000 (16:16 +0100)
commited2cddb66b40cacdefd2e7920bde578d8da67fa9
treea04d867cafc8a24cd1afec63f0124dce37d649aa
parentb13981ff7a5e57798b8dd802c9ee3ba79914e75b
xen/arm: p2m: Release the p2m lock before undoing the mappings

Since commit 4b25423a "arch/arm: unmap partially-mapped memory regions",
Xen has been undoing the P2M mappings when an error occurred during
insertion or memory allocation.

This is done by calling recursively apply_p2m_changes, however the
second call is done with the p2m lock taken which will result in a
deadlock for the current processor.

The p2m lock is here to protect 2 threads modifying concurrently the
page tables. However, it does not guarantee the ordering of the
changes. I.e if 2 threads request change on regions that overlaps,
then the result is undefined.

Therefore it is fine to move the recursive call to undo the changes
after the lock is released.

Signed-off-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Wei Chen <Wei.Chen@arm.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Tested-by: Wei Chen <Wei.Chen@arm.com>
xen/arch/arm/p2m.c